package thread;

class MyRunnable implements Runnable{
    @Override
    public void run(){
        while (true){
            System.out.println("thread");
            try{
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }
}
public class Demo3 {
    public static void main(String[] args) {
        Thread t = new Thread(new MyRunnable());//通过Runnable来描述线程  Thread只负责执行
        t.start();

        while (true){
            System.out.println("main");
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }
}
